<style>
input{
    width: 220px;
}
input[type="password"]{
    width: 210px;
}
    div.form label {
        min-width: 90px;
    }

div.buttons{
    background-image: url("/easyui/images/linkbutton_bg.png");
    background-position: right 0;
    background-repeat: no-repeat;
    border-radius: 5px 5px 5px 5px;
    color: #444444;
    cursor: pointer;
    display: inline-block;
    float: right;
    font-size: 12px;
    height: 24px;
    outline: medium none;
    padding-right: 18px;
    text-decoration: none;
    float: left;
}
input[type="submit"]{
    background: url("/easyui/images/button_span_bg.gif") no-repeat scroll left top transparent;
    display: inline-block;
    height: 24px;
    line-height: 18px;
    padding: 4px 0 4px 18px;
    border: 0;
}
div.row label{
    min-width: 80px;
}
input[disabled], select[disabled], textarea[disabled], input[readonly], select[readonly], textarea[readonly] {
    cursor:pointer;
}
select.combo{
    width: auto;
}
div#time1,div#time2,input#Imgs_ctime, input#Imgs_utime{
    float: left;
    display: inline-block;
}
div#time1{
    margin-right: 20px;;
}
img.clock{
    display: none;
}
div#ui-datepicker-div{display: none;}
</style>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'user-form',
	'enableAjaxValidation'=>true,
	'htmlOptions' => array('enctype'=>'multipart/form-data'),
));
?>

	<?php echo $form->errorSummary(array($model,$profile)); ?>

	<div class="row">
		<?php echo $form->labelEx($model,'username'); ?>
		<?php echo $form->textField($model,'username',array('size'=>20,'maxlength'=>20)); ?>
		<?php echo $form->error($model,'username'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'password'); ?>
		<?php echo $form->passwordField($model,'password',array('size'=>60,'maxlength'=>128)); ?>
		<?php echo $form->error($model,'password'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'email'); ?>
		<?php echo $form->textField($model,'email',array('size'=>60,'maxlength'=>128)); ?>
		<?php echo $form->error($model,'email'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'superuser'); ?>
		<?php echo $form->dropDownList($model,'superuser',User::itemAlias('AdminStatus')); ?>
		<?php echo $form->error($model,'superuser'); ?>
	</div>

	<div class="row">
		<?php echo $form->labelEx($model,'status'); ?>
		<?php echo $form->dropDownList($model,'status',User::itemAlias('UserStatus')); ?>
		<?php echo $form->error($model,'status'); ?>
	</div>

<?php 
		$profileFields=$profile->getFields();
		if ($profileFields) {
			foreach($profileFields as $field) {
			?>
	<div class="row">
		<?php echo $form->labelEx($profile,$field->varname); ?>
		<?php 
		if ($widgetEdit = $field->widgetEdit($profile)) {
			echo $widgetEdit;
		} elseif ($field->range) {
			echo $form->dropDownList($profile,$field->varname,Profile::range($field->range));
		} elseif ($field->field_type=="TEXT") {
			echo CHtml::activeTextArea($profile,$field->varname,array('rows'=>6, 'cols'=>50));
		} else {
			echo $form->textField($profile,$field->varname,array('size'=>60,'maxlength'=>(($field->field_size)?$field->field_size:255)));
		}
		 ?>
		<?php echo $form->error($profile,$field->varname); ?>
	</div>
			<?php
			}
		}
?>

    <div class="row">
        <label for="group">所属群组</label>

<?php
$groups = Group::model()->findAll();
foreach($groups as $group):
?>
        <input type="checkbox" value="<?php echo $group->id;?>" id="group-<?php echo $group->id;?>" name="Group[]" <?php
        if(isset($model->id) && $model->id>0){
            $ug=UserGroup::model()->findByAttributes(array('gid'=>$group->id,'uid'=>$model->id));
            if(!empty($ug)){
                echo 'checked="checked"';
            }
        }
        ?>/>
        <label style="display: inline-block;float: none;margin: 0;" for="group-<?php echo $group->id;?>"><?php echo $group->name;?></label>
<?php endforeach;?>

    </div>

	<div class="row buttons">
		<?php echo CHtml::submitButton($model->isNewRecord ? UserModule::t('Create') : UserModule::t('Save')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- form -->